<template>
	<div class="page">
		<div class="table-view" v-infinite-scroll="getData" infinite-scroll-disabled="loading" infinite-scroll-distance="20">
		  <li class="cell" v-for="(s,index) in items">
		  	<div style="padding-left: 15px;">
		  		<div>
		  			<span>类型：</span><span>{{s.type == 'consume'?'消费':'充值'}}</span>
		  		</div>
		  		<div>
		  			<span>次数：</span><span>{{s.times}}</span>
		  		</div>
		  		<div>
		  			<span>操作时间：</span><span>{{s.createDate | formatDate}}</span>
		  		</div>
		  	</div>
		  </li>
		</div>
	</div>
</template>


<style>
	@import url("purchase-history.css");
	@import url("../../common/common.css");
</style>
<script>
	import $ from 'jquery'
	export default{
		name:'register',
		data:function(){
			return {
				items:[
				],
				openId:'',
				type:'',
				loading:false,
				pageNo:0
			}
		},
		created(){
			this.openId = this.$route.params.openId;
			this.type = this.$route.params.type;
			document.title = (this.type == 'consume'?'消费':'充值')+'记录'
		},
		methods:{
			getData(){
				var _self = this;
				this.loading = true;
				if(_self.pageNo == 0){
					_self.items = [];
				}
				_self.pageNo++;
				this.$Spin.show();
				$.ajax({
				  	type:"post",
				  	contentType:'application/json;charset=UTF-8',
				  	url:this.utils.rootUrl + "gameTimer/rclist?pageSize=10&pageNo="+_self.pageNo,
				  	data:JSON.stringify({
				  		openId:_self.openId,
				  		type:_self.type
				  	}),
				  	success:function(res){
				  		_self.$Spin.hide();
				  		_self.loading = false;
				  		if(res.dataList.length == 0){
				  			_self.loading = true;
				  		}
				  		for(var index in res.dataList){
				  			var item = res.dataList[index];
				  			_self.items.push(item);
				  		}
				  	},
				  	error:function(e){
				  		_self.$Spin.hide();
				  		_self.loading = true;
				  	}
				  });
			}
		},
        filters: {
	        formatDate(time) {
	        	var str = new Date(parseInt(time)).toISOString().substr(0,16);
	        	
	            return str.replace('T','	');
	        }
	    }
	}
</script>

